/**
 *
 */
package cc.aileron.commons.util.function;

import java.util.Collection;
import java.util.List;

/**
 * @author aileron
 * @param <P>
 * @param <R>
 */
public abstract class Flod<P, R> implements FlodFunction<P, R>,
        CollectionFunction<P, R>
{
    @Override
    public R get(final List<P> list)
    {
        return CollectionFunctions.<P, R> flod(list).apply(this);
    }

    @Override
    public final R get()
    {
        if (list == null)
        {
            throw new UnsupportedOperationException();
        }
        return CollectionFunctions.<P, R> flod(list).apply(this);
    }

    /**
     * default constrator
     */
    public Flod()
    {
        list = null;
    }

    /**
     * @param list
     */
    public Flod(final Collection<P> list)
    {
        this.list = list;
    }

    private final Collection<P> list;
}
